package com.cleaningcloud.erp.api;

import com.cleaningcloud.common.core.constant.SecurityConstants;
import com.cleaningcloud.common.core.constant.ServiceNameConstants;
import com.cleaningcloud.common.core.domain.R;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.erp.api.domain.ErpWareCommodityNumber;
import com.cleaningcloud.erp.api.domain.ErpWareHouse;
import com.cleaningcloud.erp.api.factory.RemoteWareFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * 仓库服务
 *
 * @author
 */
@FeignClient(contextId = "remoteWareService", value = ServiceNameConstants.ERP_SERVICE, fallbackFactory = RemoteWareFallbackFactory.class)
public interface RemoteWareService {


    /**
     * 新增仓库
     *
     * @param wareHouse 仓库信息
     * @return 结果
     */
    @RequestMapping("/ErpWareHouse")
    AjaxResult addWare(@RequestBody ErpWareHouse wareHouse, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 根据岗位仓id修改仓库名称
     *
     * @param wareHouse 仓库信息
     * @return 结果
     */
    @RequestMapping("/ErpWareHouse/updateWareNameByPostId")
    AjaxResult updateWareNameByPostId(@RequestBody ErpWareHouse wareHouse, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 新增仓库
     *
     * @param wareHouse 仓库信息
     * @return 结果
     */
    @RequestMapping("/ErpWareHouse/closureWareHouse/{projectId}")
    AjaxResult closureWareHouse(@PathVariable("projectId") Long projectId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 根据项目id查询仓库信息
     *
     * @param erpWareHouse 项目id
     * @return 结果
     */
    @RequestMapping("/ErpWareHouse/getWareHouseByProjectId/{projectId}")
    ErpWareHouse getWareHouseByProjectId(@PathVariable("projectId") Long projectId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 根据项目id查询仓库信息
     *
     * @param postId 岗位ID
     * @return 结果
     */
    @RequestMapping("/ErpWareHouse/getWareHouseByPostId/{postId}")
    ErpWareHouse getWareHouseByPostId(@PathVariable("postId") Long postId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 批量新增仓库
     *
     * @param list 仓库信息
     * @return 结果
     */
    @RequestMapping("/ErpWareHouse/batchAddWare")
    R<Boolean> batchAddWare(@RequestBody List<ErpWareHouse> list, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 根据商品id和仓库id查询商品库存
     *
     * @param erpWareCommodityNumber 仓库信息
     * @return 结果
     */
    @RequestMapping("/common/selectByCommodityIdAndWareId")
    ErpWareCommodityNumber selectByCommodityIdAndWareId(@RequestBody ErpWareCommodityNumber erpWareCommodityNumber, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 修改仓库库存
     *
     * @param erpWareCommodityNumber 仓库信息
     * @return 结果
     */
    @RequestMapping("/common/updateErpWareCommodityNumber")
    R<Boolean> updateErpWareCommodityNumber(@RequestBody ErpWareCommodityNumber erpWareCommodityNumber, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 新增仓库库存
     *
     * @param erpWareCommodityNumber 仓库信息
     * @return 结果
     */
    @RequestMapping("/common/insertErpWareCommodityNumber")
    R<Boolean> insertErpWareCommodityNumber(@RequestBody ErpWareCommodityNumber erpWareCommodityNumber, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

}
